package graphique;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class CalDateN extends JFrame{

	private Calendrier c;
	private JButton bouton;
	private String date;
	
	public CalDateN(final FormulaireCompte fc){
		super();
		this.setSize(600, 470);
		this.setLocationRelativeTo(null);
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(new BorderLayout());
		JPanel pan = new JPanel();
		JPanel pan2 = new JPanel();
		c = new Calendrier();
		pan.add(c);
		bouton = new JButton("OK");
		bouton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				date = c.getDt();
				fc.setDateUser(date);
				dispose();
			}
		});
		pan2.add(bouton);
		this.add(pan, BorderLayout.NORTH);
		this.add(pan2, BorderLayout.SOUTH);
		this.setAlwaysOnTop(true);
		//this.setVisible(true);
	}
	
	public CalDateN(final FormulaireContact fc){
		super();
		this.setSize(600, 470);
		this.setLocationRelativeTo(null);
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(new BorderLayout());
		JPanel pan = new JPanel();
		JPanel pan2 = new JPanel();
		c = new Calendrier();
		pan.add(c);
		bouton = new JButton("OK");
		bouton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				date = c.getDt();
				fc.setDateContact(date);
				dispose();
			}
		});
		pan2.add(bouton);
		this.add(pan, BorderLayout.NORTH);
		this.add(pan2, BorderLayout.SOUTH);
		this.setAlwaysOnTop(true);
		//this.setVisible(true);
	}
	
	

	public String getDate(){
		return date;
	}
	
	
}
